<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <base href="<%= basePath %>"/>
    <title>Insert title here</title>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <script type="text/javascript" src="pages/js/pagination.js"></script>
    <style>
        /* 重置与基础布局 */
        body {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            background-color: #f5f7fa;
        }
        .container {
            width: 90%;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        h1 {
            margin-bottom: 20px;
            font-size: 24px;
            color: #333;
            border-left: 5px solid #008c8c;
            padding-left: 10px;
        }

        /* 按钮与表单排版 */
        a[href="pages/supplierAdd.jsp"] {
            display: inline-block;
            text-decoration: none;
            padding: 8px 15px;
            background-color: #008c8c;
            color: #fff;
            border-radius: 4px;
            margin-right: 20px;
        }
        form {
            display: inline-block;
            vertical-align: middle;
        }
        form input[type="text"] {
            padding: 6px 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            margin-right: 8px;
        }
        form input[type="submit"] {
            padding: 6px 15px;
            background-color: #409eff;
            color: #fff;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }

        /* 表格样式 */
        .table-wrapper {
            overflow-x: auto;
            margin-top: 20px;
        }
        table{
            width: 100%;
            border-collapse: collapse;
            min-width: 800px;
        }
        table caption{
            font-size: 2em;
            font-weight: bold;
            margin: 1em 0;
        }
        th,td{
            border: 1px solid #999;
            text-align: center;
            padding: 12px 8px;
            word-break: break-all;
        }
        table thead tr{
            background-color: #008c8c;
            color: #fff;
        }
        table tbody tr:nth-child(odd){
            background-color: #eee;
        }
        table tbody tr:hover{
            background-color: #ccc;
        }
        table tbody tr td:first-child{
            color: #f40;
        }
        table tfoot tr td{
            text-align: right;
            padding-right: 20px;
        }

        /* 分页按钮 */
        body > a {
            display: inline-block;
            text-decoration: none;
            padding: 6px 12px;
            color: #409eff;
            border: 1px solid #409eff;
            border-radius: 4px;
            margin: 0 5px;
            margin-top: 15px;
        }
        body > a:hover {
            background-color: #409eff;
            color: #fff;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>供应商管理</h1>
</div>
<a href="pages/supplierAdd.jsp">添加供应商</a>&nbsp;
<a href="ContractSServlet">合同管理</a>&nbsp;
<form method="post" action="SupplierSServlet?method=select">
    供应商姓名：<input type="text" name="contractname" value="${contractname}">
    供应商电话：<input type="text" name="phone" value="${phone}">
    <input type="submit" value="查询">
</form>

<div class="table-wrapper">
    <table>
        <thead>
        <tr>
            <th>id</th>
            <th>企业</th>
            <th>合伙人</th>
            <th>电话</th>
            <th>电子邮件</th>
            <th>地址</th>
            <th>合同ID</th>
            <th>创建时间</th>
            <th>修改时间</th>
            <th>删除状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${suppliers}" var="supplier">
            <tr>
                <td>${supplier.id}</td>
                <td>${supplier.name}</td>
                <td>${supplier.contactperson}</td>
                <td>${supplier.phonenumber}</td>
                <td>${supplier.email}</td>
                <td>${supplier.address}</td>
                <td>${supplier.contractid}</td>
                <td>${supplier.createtime}</td>
                <td>${supplier.updatetime}</td>
                <td>${supplier.isdeleted}</td>
                <td><a href="SupplyChangeServlet?method=updateBefore&id=${supplier.id}">修改</a>
                    <a href="DeleteSuppliesServlet?id=${supplier.id}">删除</a></td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>

<a href="SupplierSServlet?page=${(page==1)?1:page-1}">上一页</a>&nbsp;
<a href="SupplierSServlet?page=1">首页</a>&nbsp;
<a href="SupplierSServlet?page=${page+1}">下一页</a>&nbsp;
</body>
</html>